﻿@model TCC.CMFlow.Models.CategoriaWorkflow

@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<!-- modal placeholder-->
<div id='myModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='myModalContent'></div>
        </div>
    </div>
</div>

<div class="panel panel-info" style="margin-top: 15px">
    <div class="panel-heading clearfix">

        <h3 class="panel-title pull-left"><strong>Categoria de Workflow</strong></h3>
        <div class="pull-right">
            @Html.ActionLink("Editar", "Edit", new { id = Model.ID }, new { @class = "btn btn-primary btn-sm", id = "btnEdit", data_modal = "" })
            @Html.ActionLink("Listar Categorias", "Index", null, new { @class = "btn btn-default btn-sm" })
        </div>

    </div>
    <div class="panel-body">

        <div>
            <dl class="dl-horizontal">
                <dt>
                    @Html.DisplayNameFor(model => model.Nome)
                </dt>

                <dd>
                    @Html.DisplayFor(model => model.Nome)
                </dd>

                <dt>
                    @Html.DisplayNameFor(model => model.Descricao)
                </dt>

                <dd>
                    @Html.DisplayFor(model => model.Descricao)
                </dd>

                <dt>
                    @Html.DisplayNameFor(model => model.InicioVigencia)
                </dt>

                <dd>
                    @Html.DisplayFor(model => model.InicioVigencia)
                </dd>

                <dt>
                    @Html.DisplayNameFor(model => model.FimVigencia)
                </dt>

                <dd>
                    @Html.DisplayFor(model => model.FimVigencia)
                </dd>

            </dl>
        </div>

        <div class="panel panel-primary">
            <div class="panel-heading clearfix">
                <h3 class="panel-title pull-left"><strong>Grupos de Aprovação</strong></h3>
                <div class="pull-right">
                    <a data-modal="" class="btn btn-primary btn-xs" href="@Url.Action("OrdenarGrupo", new { id = Model.ID })" id="btnOrdenar"><span class="glyphicon glyphicon-sort"></span> Ordenar Aprovação</a>
                    <a data-modal="" class="btn btn-primary btn-xs" href="@Url.Action("AdicionarGrupo", new { id = Model.ID })" id="btnAdicionar"><span class="glyphicon glyphicon-plus"></span> Adicionar Grupos</a>
                </div>
            </div>
            <div class="panel-group" id="accordion">
                @foreach (var item in Model.CategoriaGrupos.OrderBy(o => o.sequenciaAprovacao))
                {
                    <div class="panel panel-default">
                        <div class="panel-heading clearfix">
                            <h3 class="panel-title pull-left">
                                <a data-toggle="collapse" data-target="#grupo@(item.GrupoAprovacaoID)" href="#grupo@(item.GrupoAprovacaoID)" style="text-decoration:none">
                                    <span class="glyphicon glyphicon-chevron-down">&nbsp;</span>
                                    <span class="badge" title="sequencia de aprovação">@Html.DisplayFor(modelItem => item.sequenciaAprovacao)</span>
                                    @Html.DisplayFor(modelItem => item.GrupoAprovacao.Nome)
                                </a>
                            </h3>
                            <div class="pull-right">
                                <a data-modal="" class="btn btn-default btn-xs" href="@Url.Action("AssociarUsuario", new { categoriaWorkflowID = item.CategoriaWorkflowID, grupoAprovacaoID = item.GrupoAprovacaoID })" id="btnAdicionar"><span class="glyphicon glyphicon-user"></span> Associar Usuários</a>
                                <a data-modal="" class="btn btn-danger btn-xs" href="@Url.Action("RemoverGrupo", new { categoriaWorkflowID = item.CategoriaWorkflowID, grupoAprovacaoID = item.GrupoAprovacaoID })" id="btnRemoverGrupo"><span class="glyphicon glyphicon-trash"></span></a>
                            </div>
                        </div>
                        <div id="grupo@(item.GrupoAprovacaoID)" class="panel-collapse collapse">
                            @Html.Partial("_CategoriaGrupoUsuarios", item.Usuarios, new ViewDataDictionary { {"CategoriaWorkflowID", item.CategoriaWorkflowID}, {"GrupoAprovacaoID", item.GrupoAprovacaoID} })
                        </div>
                    </div>
                }
            </div>
        </div>

        @Html.Partial("_CategoriaWebService", Model.CategoriaWebService)

    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/modalform")
}